package com.itheima.sh.g_polymorphic;

public class Test {
    //目标：认识多态
    public static void main(String[] args) {
//        People p1 = new Teacher();
//        System.out.println(p1.name);
//        p1.run();
//
//        People p2 = new Student();
//        System.out.println(p2.name);
//        p2.run();

//        Teacher t = new Teacher();
//        go(t);

        Student s = new Student();
        go(s);
    }


    public static void go(People p) {
        System.out.println("----开始-----------");
        p.run();
       if (p instanceof Student){
           Student s= (Student) p;
           s.study();
       }else if (p instanceof Teacher){
           Teacher t= (Teacher) p;
           t.teach();
       }
        System.out.println("-----结束-----------");
    }


}
